#
# find_elements(By.CSS_SELECTOR, xx)
# tag名： 
# id：    
# class名 ：
# 子元素 ：
# 后代元素
# 根据属性来选择： 
#        [id]这样写其实也能选择到元素，选的就是具有id属性的所有元素
#        [id = "sdf"]这样选择的就是id= sdf的元素
#       div[id = "dsd"]
#       div[id *= "dsd"]
#       div[id ^= "dsd"]
#       div[id $= "dsd"]
#      div[id $= "dsd"][type]  具有多个属性
#    注意：一定是双引号！

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from changliang import LUJING
import time



def getsomething():
    name = input('请输入你想查询的岗位：')
    wd = webdriver.Chrome(service=Service(LUJING))
    wd.implicitly_wait(10)
    wd.get('http://www.51job.com')

    search_k = wd.find_element(By.CSS_SELECTOR,'#kwdselectid')
    search_k.clear()
    search_k.send_keys(name)

    wd.find_element(By.CSS_SELECTOR,'#work_position_input').click()
    time.sleep(2)
    loc_table = wd.find_element(By.CSS_SELECTOR,'#work_position_click_center_right_list_000000')
    for i in loc_table.find_elements(By.CSS_SELECTOR,'td'):
        if i.text == '成都':
            i.find_element(By.CSS_SELECTOR,'em').click()
    wd.find_element(By.CSS_SELECTOR,'#work_position_click_bottom_save').click()

    wd.find_element(By.CSS_SELECTOR,'.radius_5  button ').click()

    ls1 = wd.find_elements(By.CSS_SELECTOR,'.joblist-item-job-wrapper')
    for i in ls1:
        # 先获取岗位  工资
        s = []
        for j in i.find_elements(By.CSS_SELECTOR,'.joblist-item-top span'):
            s.append(j.text)
        name1 = i.find_element(By.CSS_SELECTOR,'.joblist-item-bot a').text
        s.append(name1)
        print(f'{"|".join(s)}')

getsomething()